<template>
	<view class="elementimg">
		<view class="container" style="padding: 500rpx 85rpx 0rpx 85rpx;">
			<!-- <uni-section title="请填写" type="line"> -->
			<view class="example">
				<!-- <view class="bdkd"> -->
					<uni-forms ref="baseForm" label-position="top" :rules="rules" :model="baseFormData"
						labelWidth="80px">
						<uni-forms-item label="姓名" required name="name">
							<uni-easyinput v-model="baseFormData.name" placeholder="请输入姓名" />
						</uni-forms-item>
						<uni-forms-item label="电话" required name="dh">
							<uni-easyinput v-model="baseFormData.dh" placeholder="电话" />
						</uni-forms-item>
						<uni-forms-item label="年龄" required name="age">
							<uni-easyinput v-model="baseFormData.age" placeholder="请输入年龄" />
						</uni-forms-item>
						<uni-forms-item label="毕业学校" required name="byxx">
							<uni-easyinput v-model="baseFormData.byxx" placeholder="毕业学校" />
						</uni-forms-item>
						<uni-forms-item label="地址" name="dz">
							<uni-easyinput v-model="baseFormData.dz" placeholder="地址" />
						</uni-forms-item>
						<uni-forms-item label="性别" required>
							<uni-data-checkbox v-model="baseFormData.sex" :localdata="sexs" />
						</uni-forms-item>
						<uni-forms-item label="自我介绍">
							<uni-easyinput type="textarea" v-model="baseFormData.introduction" placeholder="请输入自我介绍" />
						</uni-forms-item>
					</uni-forms>
					<button style="background-color:#29784b" type="primary" @click="submit('baseForm')">提交</button>
				<!-- </view> -->
				<!-- </uni-section> -->
			</view>
		</view>
	</view>
</template>


<script>
	import uniForms from "@/pages_bd/components/uni-forms/uni-forms";
	import uniFormsItem from "@/pages_bd/components/uni-forms-item/uni-forms-item";
	var vk = uni.vk;
	export default {
		components: {
			uniForms,
			uniFormsItem
		},
		data() {
			// 页面数据变量
			return {
				// 校验规则
				rules: {
					dh: {
						rules: [{
							required: true,
							errorMessage: '电话'
						}, {
							format: 'number',
							errorMessage: '电话只能输入数字'
						}]
					},
					name: {
						rules: [{
							required: true,
							errorMessage: '姓名'
						}]
					},
					age: {
						rules: [{
							required: true,
							errorMessage: '年龄'
						}, {
							format: 'number',
							errorMessage: '年龄只能输入数字'
						}]
					},
					byxx: {
						rules: [{
							required: true,
							errorMessage: '毕业学校'
						}]
					},
				},
				// 单选数据源
				sexs: [{
					text: '男',
					value: 0
				}, {
					text: '女',
					value: 1
				}],
				// 多选数据源
				hobbys: [],
				// 城市数据
				cityData: [],
				skillsRange: [],
				// 基础表单数据
				baseFormData: {
					sex: 0
				},
				// init请求返回的数据
				data: {

				},
				// 表单请求数据
				form1: {

				},
				scrollTop: 0,
			}
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		// 监听 - 页面每次【加载时】执行(如：前进)
		onLoad(options = {}) {
			vk = uni.vk;
			this.options = options;
			this.init(options);
		},
		// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快，会在页面进入动画完成前触发
		onReady() {

		},
		// 监听 - 页面每次【显示时】执行(如：前进和返回) (页面每次出现在屏幕上都触发，包括从下级页面点返回露出当前页面)
		onShow() {

		},
		// 监听 - 页面每次【隐藏时】执行(如：返回)
		onHide() {

		},
		// 监听 - 点击右上角转发时
		onShareAppMessage(options) {

		},
		// 函数
		methods: {
			addzsbd() {
				// 回调形式 success fail complete
				vk.callFunction({
					url: 'client/gghs/gsxy-wx-zsbd.adddemoobjapi',
					title: '请求中...',
					data: {
						...this.baseFormData
					},
					success: (data) => {
						//console.log(data)
						uni.showToast({
							title: "提交完毕",
							icon: "none"
						});
						this.baseFormData = {
							sex: 0
						}
					}
				});
			},
			submit(ref) {
				//console.log(this.baseFormData);
				this.$refs[ref].validate().then(res => {
					//console.log('success', res);
					// uni.showToast({
					// 	title: `校验通过`,icon:'none'
					// })
					this.addzsbd()
				}).catch(err => {
					console.log('err', err);
				})
			},
			// 页面数据初始化函数
			init(options) {
				//vk.reLaunch("/pages_template/uni-id/index/index");
			},
			pageTo(path) {
				vk.navigateTo(path);
			}
		},
		// 监听器
		watch: {

		},
		// 计算属性
		computed: {

		}
	}
</script>
<style lang="scss" scoped>
	.bdkd {
		width: 80%;
	}

	.elementimg {
		background-image: url('https://mp-7c5f2fa7-1d2c-41f1-b3dd-1f45e490fd36.cdn.bspapp.com/2024/08/13/32652159-19679821-0.jpg');
		background-size: 100% 100%;
		background-repeat: no-repeat;
		/* 或者使用具体的值，比如 100px 200px */
		height: 1100px;
	}
</style>